{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# User's Guide, Chapter 4: Lists, Streams (I) and Output"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the last two chapters, I introduced the concept of\n",
    ":class:`~music21.note.Note` objects which are made up of\n",
    ":class:`~music21.pitch.Pitch` and :class:`~music21.duration.Duration`\n",
    "objects, and we even displayed a Note on a staff and played it\n",
    "via MIDI.  But unless you're challenging Cage and Webern for the\n",
    "status of least musical material, you will probably want to\n",
    "analyze, manipulate, or create more than one Note.\n",
    "\n",
    "Python has ways of working with multiple objects and `music21`\n",
    "extends those ways to be more musical.  Let's look at how\n",
    "Python does it first and then see how `music21` extends these\n",
    "ways.  (If you've been programming for a bit, or especially\n",
    "if you have Python experience, skip to the section on\n",
    "Streams below after creating the objects `note1`, `note2` and\n",
    "`note3` described below)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Say you have two notes, a C and an F# in the middle of the treble staff. \n",
    "(If the concept of working with a tritone bothers you, go ahead and make\n",
    "the second note a G; we won't mind; we'll just call you Pope\n",
    "Gregory from now on).  Lets create those notes:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Working with multiple objects via Lists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from music21 import *\n",
    "note1 = note.Note(\"C4\")\n",
    "note2 = note.Note(\"F#4\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's make the first note a half note by modifying its duration (by default\n",
    "all `Note` objects are quarter notes):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.0"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "note1.duration.type = 'half'\n",
    "note1.duration.quarterLength"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "note2.duration.quarterLength"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To print the `step` (that is, the name without any octave or accidental\n",
    "information) of each of these notes, you could do something like this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C\n"
     ]
    }
   ],
   "source": [
    "print(note1.step)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "F\n"
     ]
    }
   ],
   "source": [
    "print(note2.step)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "But suppose you had thirty notes?  Then it'd be a pain to type \"`print(noteX.step)`\"\n",
    "thirty times.  Fortunately, there's a solution: we can put each of the \n",
    "note objects into a `List` which is a built in Python object that stores multiple\n",
    "other objects (like Notes or Chords, or even things like numbers).  To create\n",
    "a list in Python, put square brackets (`[]`) around the things that you want\n",
    "to put in the list, separated by commas.  Let's create a list called `noteList`\n",
    "that contains note1 and note2:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "noteList = [note1, note2]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can check that `noteList` contains our Notes by printing it:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[<music21.note.Note C>, <music21.note.Note F#>]\n"
     ]
    }
   ],
   "source": [
    "print(noteList)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The list is represented by the square brackets around the end with the comma in between them, just like how they were created originally.  The act of creation is mirrored in the representation.  That's nice.  Medieval philosophers would approve.\n",
    "\n",
    "Now we can write a two-line program that will print the step of each note in noteList. Most modern languages have a way of doing some action for each member (\"element\") in a list (also called an \"array\" or sometimes \"row\").  In Python this is the \"for\" command. When you type these lines, make sure to type the spaces at the start of the second line.  (When you're done typing `print(thisNote.step)`, you'll probably have to hit enter twice to see the results.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C\n",
      "F\n"
     ]
    }
   ],
   "source": [
    "for thisNote in noteList:\n",
    "    print(thisNote.step)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "What's happening here? What ``for thisNote in noteList:`` says is that Python should\n",
    "take each note in noteList in order and temporarily call that note \"`thisNote`\" (you\n",
    "could have it called anything you want; `myNote`, `n`, `currentNote` are all good\n",
    "names, but `note` is not because `note` is the name of a module).  Then the \":\" at\n",
    "the end of the line indicates that everything that happens for a bit will apply\n",
    "to every `Note` in noteList one at a time.  How does Python know when \"a bit\" is\n",
    "over?  Simple: every line that is a part of the loop needs to be indented by putting\n",
    "in some spaces. (I usually use four spaces or hit tab.  Some people use two spaces. Just be consistent.)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Loops don't save much time here, but imagine if noteList had dozens or hundreds\n",
    "of Notes in it?  Then the ability to do something to each object becomes more and\n",
    "more important."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's add another note to noteList.  First let's create another note, a low B-flat:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "note3 = note.Note(\"B-2\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Then we'll append that note to the end of noteList:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "noteList.append(note3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Lists can be manipulated or changed.  They are called \"mutable\" objects (we'll learn about immutable objects later). Streams, as we will see, can be manipulated the same way through `.append()`.\n",
    "\n",
    "We can see that the length of noteList is now 3 using the `len()` function:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(noteList)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And if we write our looping function again, we will get a third note:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C\n",
      "F\n",
      "B\n"
     ]
    }
   ],
   "source": [
    "for thisNote in noteList:\n",
    "    print(thisNote.step)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can find out what the first note of noteList is by writing:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<music21.note.Note C>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "noteList[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Notice that in a list, the first element is `[0]`, not `[1]`.  There are all \n",
    "sorts of historical reasons why computers start counting lists with zero\n",
    "rather than one--some good, some obsolete--but we need to live with this\n",
    "if we're going to get any work done. Think of it like how floors are numbered\n",
    "in European buildings compared to American buildings.  If we go forward one note, \n",
    "to the second note, we write:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<music21.note.Note F#>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "noteList[1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can also ask `noteList` where is `note2` within it, using the `index()` method:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "noteList.index(note2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If we want to get the last element of a list, we can write:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<music21.note.Note B->"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "noteList[-1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Which is how basements are numbered in Europe as well.  This is the same\n",
    "element as `noteList[2]` (our third Note), as we can have Python prove:`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "noteList[-1] is noteList[2]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Lists will become important tools in your programming, but they don't know\n",
    "anything about music.  To get some intelligence into our music we'll need to\n",
    "know about a `music21` object similar to lists, called a :class:`~music21.stream.Stream`."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Introduction to Streams"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The :class:`~music21.stream.Stream` object and its subclasses (Score, \n",
    "Part, Measure) are the fundamental containers for music21 objects such\n",
    "as :class:`~music21.note.Note`, :class:`~music21.chord.Chord`, \n",
    ":class:`~music21.clef.Clef`, :class:`~music21.meter.TimeSignature` objects. \n",
    "\n",
    "A container is like a Python list (or an array in some languages).  \n",
    "\n",
    "Objects stored in a Stream are generally spaced in time; each stored object has \n",
    "an offset usually representing how many quarter notes it lies from the beginning \n",
    "of the Stream.  For instance in a 4/4 measure of two half notes, the first note\n",
    "will be at offset 0.0, and the second at offset 2.0. \n",
    "\n",
    "Streams, further, can store other Streams, permitting a wide variety of nested, \n",
    "ordered, and timed structures.  These stored streams also have offsets.  So if\n",
    "we put two 4/4 Measure objects (subclasses of Stream) into a Part (also a \n",
    "type of Stream), then the first measure will be at offset 0.0 and the second\n",
    "measure will be at offset 4.0.  \n",
    "\n",
    "Commonly used subclasses of Streams include the :class:`~music21.stream.Score`, \n",
    ":class:`~music21.stream.Part`, and :class:`~music21.stream.Measure`. It is \n",
    "important to grasp that any time we want to collect and contain a group of \n",
    "music21 objects, we put them into a Stream. Streams can also be used for \n",
    "less conventional organizational structures. We frequently will build and pass \n",
    "around short-lived, temporary Streams, since doing this opens up a wide variety \n",
    "of tools for extracting, processing, and manipulating objects on the Stream. \n",
    "For instance, if you are looking at only notes on beat 2 of any measure, you'll\n",
    "probably want to put them into a Stream as well.\n",
    "\n",
    "A critical feature of music21's design that distinguishes it from other \n",
    "music analysis frameworks is that one music21 object can be \n",
    "simultaneously stored (or, more accurately, referenced) in more than one Stream. \n",
    "For examples, we might have numerous :class:`~music21.stream.Measure` Streams \n",
    "contained in a :class:`~music21.stream.Part` Stream. If we extract a region of \n",
    "this Part (using the :meth:`~music21.stream.Stream.measures` method), we get a \n",
    "new Stream containing the specified Measures and the contained notes. We have \n",
    "not actually created new \n",
    "notes within these extracted measures; the output Stream simply has references \n",
    "to the \n",
    "same objects. Changes made to Notes in this output Stream will be simultaneously \n",
    "reflected in Notes in the source Part.   There is one limitation though:\n",
    "the same object should not appear twice in one hierarchical structure of Streams.\n",
    "For instance, you should not put a note object in both measure 3 and measure 5\n",
    "of the same piece -- it can appear in measure 3 of one piece and measure 5 of\n",
    "another piece. (For instance, if you wanted to track a particular note's context\n",
    "in an original version of a score and an arrangement). Most users will never\n",
    "need to worry about these details: just know that this feature lets music21\n",
    "do some things that no other software package can do."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Creating simple Streams"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Objects stored in Streams are called elements and must be some type of Music21Object (don’t worry, almost everything in music21 is a Music21Object, such as Note, Chord, TimeSignature, etc.).\n",
    "\n",
    "(If you want to put an object that's not a Music21Object in a Stream, \n",
    "put it in an :class:`~music21.base.ElementWrapper`.) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Streams are similar to Python lists in that they hold individual elements\n",
    "in order.  They're different in that they can only hold `music21` objects\n",
    "such as Notes or :class:`~music21.clef.Clef` objects.  But they're a lot\n",
    "smarter and more powerful.\n",
    "\n",
    "To create a Stream you'll need to type `stream.Stream()` and assign it to\n",
    "a variable using the equal sign.  Let's call our Stream `stream1`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "stream1 = stream.Stream()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Notice that just like how the (capital) `Note` object lives in a module\n",
    "called (lowercase) `note`, the (capital) `Stream` object lives in a module\n",
    "called (lowercase) `stream`.  Variable names, like `stream1` can be either\n",
    "uppercase or lowercase, but I tend to use lowercase variable names (or camelCase\n",
    "like we did with `noteList`).  \n",
    "The most common use of Streams is as places to store Notes. So let's do just that: we can add the three `Note` objects we created above by using the `append` method of `Stream`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "stream1.append(note1)\n",
    "stream1.append(note2)\n",
    "stream1.append(note3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Of course, this would be a pain to type for hundreds of `Notes`, so we could also use the Stream method :meth:`~music21.stream.Stream.repeatAppend` to add a number of independent, unique copies of the same Note. This creates independent copies (using Python's `copy.deepcopy` function) of the supplied object, not references."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAekAAABiCAYAAAB0zis4AAAACXBIWXMAAB7CAAAewgFu0HU+AAATv0lEQVR4nO3dfbwcVX3H8U+Sm+Qm5PnZAAmQkECQgCFAEAwQhCjYVEAK1lJEsbUiBavUhxa0glRKgFAFUUxBFJ+BAFIfSqA1QBBrRFoIT5JEIOTBPBFCSHKT2z9+M525s3Nmn+bM7r37fb9e+9rZmbO7v3vuTc7MmXN+B4o3B1gPbAOmNeD7RUREJMV5wC6gM3g8BQxoaEQiIiLCOcBuogY6fFzVyKBERERa3ZHADkob6M5g/0GNC01ERKR1DQVeJL2BDh93Nyw6ERGRFnY92Q10J7AHOLxRAYqIiLSiA4GdlG+kO4EfNihGERGRlnQr5RvnTcHzLmB8Y8IUERFpLeNxDxbrxK6w5wPDgFeDfV9oRKAiIiKt5pO4G+hXgLfHyn4n2L+i4BhFRERa0sOkN9DPAOMSZS+OHT+mwBhFRERaTjvQQWkDvYL0+85zYmUWFBSjiIhIS5pJ+j3oIx3lJ9H1SltEREQ8+QCljfTlGeWHJ8ru7TtAERGRZtfb0+cOT7xeDVyTUf6NxOvj8g1HRESk+/HVSA9OvL4a2J5RPrkS1iH5hiMiItL9+Gqke8W2d2JTrLIMSbw+ON9wurU+2GC6v2l0ICIi0jN8huj+8k8qKD+brvekf+kvtG5nf6xOVjU6EBERKZavK+ldse1HKij/1sTroTnG0l0MACam7O+TeBYRkRbhq5F+M7a9rILyRydet+UYS3dxB7ASmNHgOEREpEn4aqS3xbbXVhDDuxP7tuQbTrcwJvEsIiItzlcj/Vpse3OZsrOB0Yl9m/INR0REpPtpAxZ6+Nx4bu75ZF8Zz0nZNwE/cTWzycHzJ4CzYvvDke/Dab06ERHp7noTLSi1jNK8IKOAgxzv/Xkb8KKHoLYApwbb64GXHeWGYw1y0jOe4ipnf+BELN5VWI/ATq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HruSc+jsjOwXmQvVgE2Nzq0ruaIREREepB6GulqJr+PKXM8vHrehCUKERERaXn1NNKbqyi7tszxcFENV9YVERGRllNPI726wnIdwM8yjvfDRoED3F9HPCIiIhKYTvlBY53AVWU+54JY2Wm+ghUREWk1K8ge1b2A7Kv1QbHPWOQ1UhERkRbzEaJGeTvwNWxe9JVYkvxyvh68twM4zFOMIiIiLakP8BuihnoRld/n/nTsfZ/1Ep2IiEiLm4CN3g4b3IfInp41CLgxVv4elPFGRETEm+lYXuOw4d0G3AacCczEurJPA64H1sTK3UnXvN0iIiLiwVjgLiob8b0N6+Lu05BIRUREWtQsbGWs1ZQ2zsux1bEmNCw6ERGRbuL/ANh6gzUBGgwUAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {
      "image/png": {
       "height": 49,
       "width": 244
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "stream2 = stream.Stream()\n",
    "n3 = note.Note('D#5') # octave values can be included in creation arguments\n",
    "stream2.repeatAppend(n3, 4)\n",
    "stream2.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "But let's worry about that later. Going back to our first stream, we can see that it has three notes using the same `len()` function that we used before:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(stream1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Alternatively, we can use the :meth:`~music21.base.Music21Object.show` method \n",
    "called as `show('text')` to see what is in the Stream and what its offset \n",
    "is (here 0.0, since we put it at the end of an empty stream)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{0.0} <music21.note.Note C>\n",
      "{2.0} <music21.note.Note F#>\n",
      "{3.0} <music21.note.Note B->\n"
     ]
    }
   ],
   "source": [
    "stream1.show('text')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you’ve setup your environment properly, then calling show with the `musicxml` argument should open up Finale Reader, or Sibelius, or MuseScore or some music notation software and display the notes below."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgwAAABvCAYAAACAeZjSAAAACXBIWXMAAB7CAAAewgFu0HU+AAAR/0lEQVR4nO3de9QcdXnA8W/uFxKSEMJFQAIJFy8o90shXIwIAsq1B9CiKEcEAQseEY9asJZzaIuUYoVyKpQeEAoVAaUWBUEMKHekTQmEcIkF5U6I3JKQN+kfz+zZffed2Xd3dmdn3/f9fs7Zs7szszO/fbPZefY3v9/zjEGS8hsDXAhsATxYclskSVKP2gJYC/y+7IZIKtboshsgaUiYBGyesnxM3b2kYcqAQVIzrgaWAjuW3A5JJTFgkNSMDeruJY0wBgySJGlQBgySJGlQBgySJGlQBgySOmlHYLuyGyGp88aW3QBJw8J6wOPANkAfsCnwQqktktRR9jBIymMGcDLw78nzSUSwAJGTYUYZjZJUHHsYJLVib+BzwKHAhJLbIkmSesjuwDNECuhmb+8rpaWSCmMPg6QsnwHOAt7f4uuWA39s47hziYGTGxG9GM8DvwWebWOfkiSpICtpvkdhDXAXcCowK8expgPnAEsa7P9mYMvc70aSJBWimUDhteT+uTaOcyqwrMnjvQDMbuNYkiSpw7JO2suAy4H5wNbkDximAzc1OE7W7cd535AkSeq8NQw8WX+d/rMj5pIvYJgJPJyy/2ZuK3GGhtR15mGQlOUSYrDh14CFybJHiBN2OyYDtwM75Hz9eCJRlCRJ6jF3E7/uD6xbnqeH4VLy9SxUbn3AuJzvQ1JO9jBI6qbtgS+2uY9FwLsdaIukFhgwSOqmkzuwj8s7sA9JLTJgkNRNh7f5+qUYMEilMGCQ1AnjiUsNtwE3Js/rz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lYs4B3DnPvcAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {
      "image/png": {
       "height": 55,
       "width": 262
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "stream1.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Accessing Streams"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can also dive deeper into streams. Let's get the `step` of each `Note` using the `for thisNote in ...:`\n",
    "command. But now we'll use `stream1` instead of `noteList`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C\n",
      "F\n",
      "B\n"
     ]
    }
   ],
   "source": [
    "for thisNote in stream1:\n",
    "    print(thisNote.step)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "And we can get the first and the last `Note` in a `Stream` by using the [X] form, just like other Python list-like objects:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<music21.note.Note C>"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stream1[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'B-2'"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stream1[-1].nameWithOctave"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "While full list-like functionality of the Stream isn't there, some additional methods familiar to users of Python lists are also available. The Stream :meth:`~music21.stream.Stream.index` method can be used to get the first-encountered index of a supplied object."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "note3Index = stream1.index(note3)\n",
    "note3Index"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Given an index, an element from the Stream can be removed with the :meth:`~music21.stream.Stream.pop` method. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZoAAABjCAYAAACi7MYGAAAACXBIWXMAAB7CAAAewgFu0HU+AAAS2ElEQVR4nO3debgU1ZnH8e+FC8h6WRRcIoKIW1gMEUXNoGJiVJRxdIxmU6PmiVkYdTJjxkwWxzg+k1GjPqMmE3U0OkYzmrjEGGNC1IjRmEeCySCIjIBEURS5LFe4F7h3/nir0tXVtXR1V3X18vs8Tz9dXUv3uUv36XPOe94DtTcHeBvoAg7O4fVFRKSJnQNsB/qc2xJgcK4lEhGRpnEWsJNCJePersqzUCIi0hxmAt2UVjJ9zv4D8yuaiIg0ug7gVYIrGff2QG6lExGRhncd0ZVMH9ALHJJXAUVEpHFNBnqIr2j6gP/JqYwiItLAbie+gtng3G8H9synmCIi0oj2JDwAoA9r6VwDjATWOvsuz6OgIiLSmL5MeCXzOnCk59z/dvavrHEZRUSkgS0kuJJZBuzuO/ciz/EjalhGERFpULsAOyitZFYSPA4zx3PO9TUqo4iINLBDCR6TmRly/iSKWzwiIiKRPklpRfONiPNH+c7dK+sCiohIbfTL6HlH+R6/AVwdcf57vscfSrc4IiKSl6wqmuG+x98Gtkac78/g/P50iyMiInnJqqJp82z3YOHLUUb4Hh+UbnFERCQvWVU0vZ7tXwLvxpw/wfd4XKqlERGR3GRV0Wz3bD9TxvlTfI87UiyLiIjkKKuKZptne1EZ5x/ue9yeYllERCRHWVU0XZ7tt8oow4m+fRvTLY6IiOQlq4pmk2e7M+bc2cBuvn0b0i2OiIjkpR24LYPn9eYyu4boFsqcgH3jyaZcItKYJmGLIz6CZYWX2psJDA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nE/4J4gOvR5GHCT5/yHUFpxv9exnHETYs47DVsoKihgYP8MyyciUnPTsAF/7wfdHcDpwKHAdGAutuKeN5Lqx1iXjxTbTnSesolYdoCwsbGzsi6giEgexmEz08sZjO7CusuiQnRb2VpsjZ69fPtHYwEE2wj+vW7AKncRkaY2C7gVC3f0fxAuBa7Autsk3Hex39cybCndU5x9mwmuYLqBG7C5NyIiLaUDGyuYSPDsdgnWgY11RbUKtwJPYvNtVMGISN36f6R5TPGMN+tyAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {
      "image/png": {
       "height": 49,
       "width": 205
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "stream1.pop(note3Index)\n",
    "stream1.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Since we removed `note3` from `stream1` with the the :meth:`~music21.stream.Stream.pop` method, let's add `note3` back into `stream1` so that we can continue with the examples below using `stream1` as we originally created it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgwAAABvCAYAAACAeZjSAAAACXBIWXMAAB7CAAAewgFu0HU+AAAR/0lEQVR4nO3de9QcdXnA8W/uFxKSEMJFQAIJFy8o90shXIwIAsq1B9CiKEcEAQseEY9asJZzaIuUYoVyKpQeEAoVAaUWBUEMKHekTQmEcIkF5U6I3JKQN+kfz+zZffed2Xd3dmdn3/f9fs7Zs7szszO/fbPZefY3v9/zjEGS8hsDXAhsATxYclskSVKP2gJYC/y+7IZIKtboshsgaUiYBGyesnxM3b2kYcqAQVIzrgaWAjuW3A5JJTFgkNSMDeruJY0wBgySJGlQBgySJGlQBgySJGlQBgySOmlHYLuyGyGp88aW3QBJw8J6wOPANkAfsCnwQqktktRR9jBIymMGcDLw78nzSUSwAJGTYUYZjZJUHHsYJLVib+BzwKHAhJLbIkmSesjuwDNECuhmb+8rpa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OGyf3FwFeJ/DPNWAIcQKSRntNgu4eBc6mmjtYQN1IDhpeAi4ADGXwu8OQG66YTuSkqzMkgqde9U/P4u0TBvVbdQ8yUOAT4CLAZMYDuRWJM2C1E5l9pRNmf7K62wS5nSFKv+TiR8v4KhnZ2XuXjJYkCZRVeAdi4a62QpM64hWpRPalpI32WRDMaVd3cp2utkCSpRAYMjc1hYL34Wp8l6klIkjSsGTBk24wY3ZtZiIOYx3wDdu9Jkoa5scBhZTeix8wHtiMGNE4cZFuAvYnc6PcB9wIPFdYySZLas11yP5P08/8GWS8cRZzkVDWDCKT6am6rk/tK3u3RxOjiscltTLJsBRZUkST1rplECoC3icRd9TYHpqS98P8BlYs4B3DnPvcAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {
      "image/png": {
       "height": 55,
       "width": 262
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "stream1.append(note3)\n",
    "stream1.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Separating out elements by class with `.getElementsByClass()`\n",
    "\n",
    "We can also gather elements based on the class (object type) of the element, by offset range, or by specific identifiers attached to the element. Gathering elements from a Stream based on the class of the element provides a way to filter the Stream for desired types of objects. The :meth:`~music21.stream.Stream.getElementsByClass` method iterates over a Stream of elements that are instances or subclasses of the provided classes. The example below gathers all :class:`~music21.note.Note` objects and then all :class:`~music21.note.Rest` objects. The easiest way to do this is to use `for` loops with `.getElementsByClass()`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<music21.note.Note C> 0.0\n",
      "<music21.note.Note F#> 2.0\n",
      "<music21.note.Note B-> 3.0\n"
     ]
    }
   ],
   "source": [
    "for thisNote in stream1.getElementsByClass(note.Note):\n",
    "    print(thisNote, thisNote.offset)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you want instead of passing the class `note.Note` you could instead pass the string `\"Note\"`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<music21.note.Note C> 0.0\n",
      "<music21.note.Note F#> 2.0\n",
      "<music21.note.Note B-> 3.0\n"
     ]
    }
   ],
   "source": [
    "for thisNote in stream1.getElementsByClass(\"Note\"):\n",
    "    print(thisNote, thisNote.offset)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "It is also possible to pass in a list of classes or strings of class names to `.getElementsByClass()` which will return anything that matches any of the classes.  Notice the `[]` marks in the next call, indicating that we are creating a list to pass to `.getElementsByClass()`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<music21.note.Note C> 0.0\n",
      "<music21.note.Note F#> 2.0\n",
      "<music21.note.Note B-> 3.0\n"
     ]
    }
   ],
   "source": [
    "for thisNote in stream1.getElementsByClass([\"Note\", \"Rest\"]):\n",
    "    print(thisNote, thisNote.offset)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Since there are no `note.Rest` objects, it's the same as above.  Oh well...\n",
    "\n",
    "`music21` has a couple of shortcuts that are equivalent to `.getElementsByClass`. For instance `.notes` is equivalent to `.getElementsByClass([\"Note\", \"Chord\"])` (we'll get to chords soon):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<music21.note.Note C>\n",
      "<music21.note.Note F#>\n",
      "<music21.note.Note B->\n"
     ]
    }
   ],
   "source": [
    "for thisNote in stream1.notes:\n",
    "    print(thisNote)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And `.notesAndRests` is equivalent to `.getElementsByClass(['Note', 'Chord', 'Rest'])`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<music21.note.Note C>\n",
      "<music21.note.Note F#>\n",
      "<music21.note.Note B->\n"
     ]
    }
   ],
   "source": [
    "for thisNote in stream1.notesAndRests:\n",
    "    print(thisNote)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Finally, there's something slightly different. `.pitches` begins with a call to `.notes`, but then returns a list  of all the pitches from every `Note` or `Chord` in the Stream:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<music21.pitch.Pitch C4>,\n",
       " <music21.pitch.Pitch F#4>,\n",
       " <music21.pitch.Pitch B-2>]"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "listOut = stream1.pitches\n",
    "listOut"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The result of a `.getElementsByClass` are not technically streams, but you can still call `.show()` on it:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{0.0} <music21.note.Note C>\n",
      "{2.0} <music21.note.Note F#>\n",
      "{3.0} <music21.note.Note B->\n"
     ]
    }
   ],
   "source": [
    "sOut = stream1.getElementsByClass(note.Note)\n",
    "sOut.show('text')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "But if you want to be absolutely sure, put the expression `.stream()` after it:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{0.0} <music21.note.Note C>\n",
      "{2.0} <music21.note.Note F#>\n",
      "{3.0} <music21.note.Note B->\n"
     ]
    }
   ],
   "source": [
    "sOut = stream1.getElementsByClass(note.Note).stream() # <-- different\n",
    "sOut.show('text')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Separating out elements by offset with `.getElementsByOffset()`\n",
    "\n",
    "The :meth:`~music21.stream.Stream.getElementsByOffset` method returns a Stream of all elements that fall either at a single offset or within a range of two offsets provided as an argument. In both cases a Stream is returned."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sOut = stream1.getElementsByOffset(3)\n",
    "len(sOut)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<music21.note.Note B->"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sOut[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Like with `.getElementsByClass()` if you want a `Stream` from `.getElementsByOffset()`, add `.stream()` to the end of it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{2.0} <music21.note.Note F#>\n",
      "{3.0} <music21.note.Note B->\n"
     ]
    }
   ],
   "source": [
    "sOut = stream1.getElementsByOffset(2, 3).stream()\n",
    "sOut.show('text')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We will do more with `.getElementsByOffset()` later when we also talk about :meth:`~music21.stream.Stream.getElementAtOrBefore` and :meth:`~music21.stream.Stream.getElementAfterElement`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## More Stream Features"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Okay, so far we've seen that `Streams` can do the same things as lists, but\n",
    "can they do more?  Let's call the analyze method on stream to get the\n",
    "ambitus (that is, the range from the lowest note to the highest note) of\n",
    "the `Notes` in the `Stream`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<music21.interval.Interval A12>"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stream1.analyze('ambitus')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's take a second to check this.  Our lowest note is `note3` (B-flat in octave 2)\n",
    "and our highest note is `note2` (F-sharp in octave 4).  From B-flat to the F-sharp\n",
    "above it, is an augmented fifth.  An augmented fifth plus an octave is an augmented\n",
    "twelfth.  So we're doing well so far.  (We'll get to other things we can analyze in\n",
    "chapter 18 and we'll see what an :class:`~music21.interval.Interval` object can do\n",
    "in chapter 15).\n",
    "\n",
    "As we mentioned earlier, when placed in a Stream, Notes and other elements also have an offset (stored in .offset) that describes their position from the beginning of the stream. These offset values are also given in quarter-lengths (QLs).\n",
    "\n",
    "Once a Note is in a Stream, we can ask for the `offset` of the `Notes` (or\n",
    "anything else) in it.  The `offset` is the position of a Note relative to the start\n",
    "of the `Stream` measured in quarter notes.  So note1's offset will be 0.0, \n",
    "since it's at the start of the Stream:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "note1.offset"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`note2`'s offset will be 2.0, since `note1` is a half note, worth two quarter notes:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.0"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "note2.offset"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And `note3`, which follows the quarter note `note2` will be at offset 3.0:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.0"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "note3.offset"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "(If we made `note2` an eighth note, then `note3`'s offset would be the floating point\n",
    "[decimal] value 2.5.  But we didn't.)  So now when we're looping we can see the offset of\n",
    "each note.  Let's print the note's offset followed by its name by putting .offset and .name\n",
    "in the same line, separated by a comma:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0 C\n",
      "2.0 F#\n",
      "3.0 B-\n"
     ]
    }
   ],
   "source": [
    "for thisNote in stream1:\n",
    "    print(thisNote.offset, thisNote.name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "(**Digression**: It's probably not too early to learn that a safer form of `.offset` is `.getOffsetBySite(stream1)`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.0"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "note2.offset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.0"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "note2.getOffsetBySite(stream1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "What's the difference?  Remember how I said that `.offset` refers to the number of quarter notes\n",
    "that the `Note` is from the front of a `Stream`? Well, eventually you may put the same `Note` in\n",
    "different places in multiple `Streams`, so the `.getOffsetBySite(X)` command is a safer way that\n",
    "specifies exactly which Stream we are talking about.  End of digression...)\n",
    "\n",
    "As a final note about offsets, the :attr:`~music21.stream.Stream.lowestOffset` property returns the minimum of all offsets for all elements on the Stream."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stream1.lowestOffset"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So, what else can we do with Streams?  Like `Note` objects, we can `show()` them in a couple of different\n",
    "ways.  Let's hear these three Notes as a MIDI file:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "tags": [
     "nbval-ignore-output"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "                <div id='midiPlayerDiv651'></div>\n",
       "                <link rel=\"stylesheet\" href=\"//cuthbertLab.github.io/music21j/css/m21.css\"\n",
       "                    type=\"text/css\" />\n",
       "                <script>\n",
       "                require.config({\n",
       "                    paths: {'music21': '//cuthbertLab.github.io/music21j/src/music21'}\n",
       "                });\n",
       "                require(['music21'], function() {\n",
       "                               mp = new music21.miditools.MidiPlayer();\n",
       "                               mp.addPlayer('#midiPlayerDiv651');\n",
       "                               mp.base64Load('data:audio/midi;base64,TVRoZAAAAAYAAQABBABNVHJrAAAAKQD/AwAA4ABAiACQPFqQAIA8AACQQlqIAIBCAACQLlqIAIAuAIgA/y8A');\n",
       "                        });\n",
       "                </script>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "stream1.show('midi')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Or let's see them as a score:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgwAAABvC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VpitPC/ASfUrdsHuCPjdbsBDxbXLEnquDuJwY3XAMfVLJ8H/Io4LwBcSXqBqkeBbds4/lJgeyIHhLrvL4mKlHcxsEcJ4BbgY2kvHEtcS2rWcKxhP58IFu4ATmTg36NRD8yalO0lqZdVMj2Opvr9NQO4jGqw8AvSvw8BNm/j2KuJIGV5G/tQe2rPaWn/vpnnvKJrSfS6qUSlzMeAI7F6m6Thr/I9V5nWOJUoEDg3eX4hcAiwMuP1eXMorCZm1t2d8/Uq2UgPGC4B1gEOAl4vuS2S1A2VHoYZxEDvXwF7EYHAMcBXiJN7ljxFA5cTP8quz/FaqXSnAW8T4xAa2RenVUoaPirp+18AnqGabK/ZrLxbAX+i+SmUvwFmd6z1aldb0ypHog2J/OmvJ/eNTGuw7jLgzZrnt9K/SJUk9ZpKD8OGyf3FwFeJ/DPNWAIcQKSRntNgu4eBc6mmjtYQN1IDhpeAi4ADGXwu8OQG66YTuSkqzMkgqde9U/P4u0TBvVbdQ8yUOAT4CLAZMYDuRWJM2C1E5l9pRNmf7K62wS5nSFKv+TiR8v4KhnZ2XuXjJYkCZRVeAdi4a62QpM64hWpRPalpI32WRDMaVd3cp2utkCSpRAYMjc1hYL34Wp8l6klIkjSsGTBk24wY3ZtZiIOYx3wDdu9Jkoa5scBhZTeix8wHtiMGNE4cZFuAvYnc6PcB9wIPFdYySZLas11yP5P08/8GWS8cRZzkVDWDCKT6am6rk/tK3u3RxOjiscltTLJsBRZUkST1rplECoC3icRd9TYHpqS98P8BlYs4B3DnPvcAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {
      "image/png": {
       "height": 55,
       "width": 262
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "stream1.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You might ask why is the piece in common-time (4/4)? This is just the default for new pieces, which is in the \n",
    "`defaults` module:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "defaults.meterNumerator"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'quarter'"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "defaults.meterDenominator"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "(Some of these examples use a system that automatically tries to get an appropriate time signature and appropriate clef; in this case, `music21` figured out that that low B-flat would be easier to see in bass clef than treble.)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We'll learn how to switch the :class:`~music21.meter.TimeSignature` soon enough."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you don't have MIDI or MusicXML configured yet (we'll get to it in a second) and you don't want to have \n",
    "other programs open up, you can show a `Stream` in text in your editor:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{0.0} <music21.note.Note C>\n",
      "{2.0} <music21.note.Note F#>\n",
      "{3.0} <music21.note.Note B->\n"
     ]
    }
   ],
   "source": [
    "stream1.show('text')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This display shows the `offset` for each element (that is, each object in the Stream) along with\n",
    "what class it is, and a little bit more helpful information.  The information is the same as\n",
    "what's called the ``__repr__`` (representation) of the object, which is what you get if you type\n",
    "its variable name at the prompt:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<music21.note.Note C>"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "note1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "By the way, Streams have a ``__repr__`` as well:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<music21.stream.Stream 0x1151920f0>"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stream1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "that number at the end is the hex form of the `.id` of the `Stream`, which is a way of identifying it.  Often\n",
    "the `.id` of a Stream will be the name of the `Part` (\"Violin II\"), but if it's undefined\n",
    "then a somewhat random number is used (actually the location of the Stream in your computer's\n",
    "memory).  We can change the `.id` of a Stream:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<music21.stream.Stream some_notes>"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stream1.id = 'some_notes'\n",
    "stream1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We could have also changed the `.id` of any of our `Note` objects, but it doesn't show up in\n",
    "the `Note`'s ``__repr__``:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<music21.note.Note C>"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "note1.id = 'my_favorite_C'\n",
    "note1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, a `Stream` is a :class:`~music21.base.Music21Object` just like a `Note` is.  This is why\n",
    "it has an `.id` attribute and, more importantly, why you can call `.show()` on it. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "What else makes a `Music21Object` what it is?\n",
    "It has a `.duration` attribute which stores a `Duration` object:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<music21.duration.Duration 4.0>"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stream1.duration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'whole'"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stream1.duration.type"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.0"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stream1.duration.quarterLength"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "(Notice that the `len()` of a `Stream`, which stands for \"length\", is not the same as the duration. \n",
    "the `len()` of a Stream is the number of objects stored in it, so `len(stream1)` is 3)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A related concept to the `.duration` of a Stream is its `.highestTime`, which is the time at which the latest element in the `Stream` ends.  Usually this is the last element of the stream's `.offset` plus its `.quarterLength`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.0"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stream1.highestTime"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Streams within Streams"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And, as a `Music21Object`, a `Stream` can be placed inside of another `Stream` object.  Let's create\n",
    "a stream, called biggerStream (for reasons that will become obvious), that holds a `Note` D# at the\n",
    "beginning"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "biggerStream = stream.Stream()\n",
    "note2 = note.Note(\"D#5\")\n",
    "biggerStream.insert(0, note2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we use the `.append` functionality to put `stream1` at the end of `biggerStream`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [],
   "source": [
    "biggerStream.append(stream1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Notice that when we call `.show('text')` on biggerStream, we see not only the presence of `note2`\n",
    "and `stream1` but also all the contents of `stream1` as well:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{0.0} <music21.note.Note D#>\n",
      "{1.0} <music21.stream.Stream some_notes>\n",
      "    {0.0} <music21.note.Note C>\n",
      "    {2.0} <music21.note.Note F#>\n",
      "    {3.0} <music21.note.Note B->\n"
     ]
    }
   ],
   "source": [
    "biggerStream.show('text') "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Notice though that the offsets, the little numbers inside curly brackets, for the elements of\n",
    "`stream1` (\"some notes\") relate only to their positions within `stream1`, not to their position\n",
    "within `biggerStream`.  This is because each `Music21Object` knows its offset only in relation\n",
    "to its containing `Stream`, not necessarily to the `Stream` containing *that* `Stream`.  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Also notice that `note1` knows that it is in `stream1` but doesn't know that it is somewhere inside\n",
    "`biggerStream`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "note1 in stream1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "note1 in biggerStream"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "sphinx_links": {
     "any": true
    }
   },
   "source": [
    "All this might not seem like much of a big deal, until we tell you that in music21, `Scores` are\n",
    "made up of `Streams` within `Streams` within `Streams`.  So if you have an orchestral score, it is\n",
    "a `Stream`, and the viola part is a `Stream` in that `Stream`, and measure 5 of the viola part is a\n",
    "`Stream` within that `Stream`, and, if there were a ''divisi'', then each ''diviso'' voice would be\n",
    "a `Stream` within that `Stream`.  Each of these `Streams` has a special name and its own class \n",
    "(:class:`~music21.stream.Score`, :class:`~music21.stream.Part`, :class:`~music21.stream.Measure`,\n",
    "and :class:`~music21.stream.Voice`), but they are all types of `Streams`.  \n",
    "\n",
    "So how do we find `note1` inside `biggerStream`?  That's what the next two chapters are about.\n",
    "\n",
    ":ref:`Chapter 5 covers Lists of Lists <usersGuide_05_listsOfLists>`.  Those with programming experience who have familiarity with\n",
    "lists of lists and defining functions might want to skip to :ref:`Chapter 6 Streams of Streams <usersGuide_06_stream2>`."
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
